﻿function validate() {
	var usernumber = document.getElementById("usernumber").value;
	var profession = document.getElementById("profession").value;
	var username = document.getElementById("username").value;
	var password = document.getElementById("password").value;
        var password1 = document.getElementById("password1").value;
        var email = document.getElementById("email").value;
	var male = document.getElementById("male").value;

	if (usernumber.length == 0) {
		alert("请输入您的学号!");
		return false;
	}
	if (profession.length == 0) {
		alert("请输入您的专业!");
		return false;
	}
	if (username.length == 0) {
		alert("请输入您的姓名!");
		return false;
	}

        if (password.length == 0) {
		alert("请输入您的密码!");
		return false;
	}
        if(password.length<6||password.length>16)
		{
		alert("请输入6到16位的密码!");
		return false;
		}
	
	if (password1.length == 0) {
		alert("请确认您的密码!");
		return false;
	}
	 if(password1.length <6|| password1.length>16)
	{
	alert("请确认6到16位的密码!");
	    return false;
	}
	 if (password1 != password) {
		alert("确认密码必须与刚输入的密码保持一致！");
		return false;
		}
         if (email.length == 0) {
		alert("请确认您的邮箱!");
		return false;
	}
        
	else if(email.match("([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+")==null){
		alert("邮箱格式不正确！");
		return false;
		}
        if (male.length == 0) {
		alert("请选择您的性别!");
		return false;
	}
    
if (usernumber.length != 0 && profession.length != 0 && username.length != 0&& password.length != 0&&password1.length!= 0&&email!=0&&male!=0)

	{

		alert("注册成功！");

	}
	return true;
}